for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
/** global: UB */
var stringFuncs = {
// conversion
toAcronym: function(smartCase = true){
var word = this;
// 3D Engine > 3DE
// Home loan > HL
if (smartCase){
word = word.toSmartCase();
}
// collect upper case
var chars = [];
for (var c = 0, cl = word.length;c<cl;c++){
var ch = word.charAt(c);
if (ch.isAlphabet() && ch == ch.toUpperCase()) {
chars.push(ch);
return chars.join("");
},
toPlural: function(){
// -ies (study -> studies)
if (word.endsWith("y") && word.length > 3) {
return word.removePostfix("y") + "ies";
// -s (dog -> dogs)
return word + "s";
toSingular: function(){
// -ies (studies -> study)
if (word.endsWith("ies") && word.length > 3) {
return word.removePostfix("ies") + "y";
// -s (dogs -> dog)
return word.removePostfix("s");
none:null
};
// register funcs
UB.registerFuncs(String.prototype, stringFuncs);